package designPatterns.chainOfResponsibility;

/**
 * 责任链
 *
 * @author zhanglinfeng
 * @date create in 2023/7/26 15:26
 */
public abstract class Handler {
    /** 下一个执行者 */
    protected Handler next = null;

    public void setNext(Handler next) {
        this.next = next;
    }

    public final void handle() {
        boolean handled = doHandle();
        if (next != null && handled) {
            next.handle();
        }
    }

    protected abstract Boolean doHandle();
}
